home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_sea_brigdoor.cog < prev    next >
Text File  |  1999-11-15  |  29KB  |  1,157 lines

  1. # Jones 3D Cog Script
  2. #
  3. # sea_BrigDoor.cog
  4. #
  5. #
  6. # [DS & revised by HB]
  7. #
  8. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  9. # ==============================================================================
  10.  
  11. symbols
  12.  
  13. # ................................. MESSAGES ...................................
  14.  
  15.     message        startup
  16.     message        activated    
  17.     message        arrived        
  18.     message        timer
  19.     message        entered
  20.     message        exited
  21.     message        touched
  22.     message        callback
  23.     message        user0
  24.     message        crossed
  25.  
  26. # ................................ KEYFRAMES ...................................
  27.     
  28.     keyframe    in_hitdoor=0in_bangdoor_1_1.key            local
  29.     keyframe    in_rtarmup=0in_armsout_1_1.key            local
  30.     keyframe    in_fall=in_die_buckle.key                local
  31.     keyframe    in_raiseHands=0in_stand1_bd_3.key        local
  32.     # keyframe    in_handsUp=0in_stand3.key                local
  33.     keyframe    in_close=in_activate_medium_left.key    local
  34.     keyframe    in_standup=0in_getup_bunkbed.key        local # 35x
  35.  
  36.     keyframe    actdoor=01h_sailor_activatemed.key        local
  37.     keyframe    acthit=01h_sailor_pistolwhip.key        local
  38.     keyframe    actlook=01h_sailor_lookaround.key        local
  39.  
  40. # ............................. INDY SAYLINES ..................................
  41.  
  42. # Door locked lines...    
  43.     sound        in_sayline=inxj077.wav                local # It's locked.
  44.     sound        in_nokey1=Inxj076.wav                local # This door...locked.
  45.     sound        in_nokey2=Inxj078.wav                local # Locked.
  46.     sound        in_nokey3=Inxj079.wav                local # Locked again.
  47.     sound        in_nokey6=Inxj088.wav                local # Nope.
  48.     sound        in_nokey4=Inxj080.wav                local # Locked...luck never changes.
  49.     sound        in_nokey5=Inxj081.wav                local # Oh no...why...always locked?
  50.  
  51. # Not going back in there...
  52.     sound        in_noway0=inxj060.wav                local # Don't think...right answer.
  53.     sound        in_noway1=Inxj061.wav                local # I'm not sure...good idea.
  54.     sound        in_noway2=Inxj096.wav                local # I can't open it.
  55.     sound        in_noway3=Inxj056.wav                local # That Looks Dangerous.
  56.     sound        in_noway6=Inxj088.wav                local # Nope.
  57.     sound        in_noway4=Inxj057.wav                local # That Looks a little too Danger...
  58.     sound        in_noway5=Inxj043.wav                local # This doesn't feel right.
  59.  
  60. # .................................. SOUNDS ....................................
  61.  
  62.     sound        opensnd=sea_doors_open_c.wav            local
  63.     sound        closesnd=sea_doors_close_c.wav        local
  64.     sound        bangdoor=sea_indy_hitdoor_c.wav        local
  65.     sound        bop_indy=sea_bop_indy.wav            local
  66.     sound        pullgun=gen_pistol_pull.wav            local    # Autoloaded
  67.     sound        ungh=inxj018a.wav                    local
  68.  
  69.  
  70.     sound        in_betterspot=inxj224.wav            local # I need to find a better spot.
  71.     sound        in_seasick=se01j02.wav                local # Quick, get me up on deck....
  72.     sound        sl_nobackup=se01q01.wav                local # No! Backup!
  73.     sound        sl_foolishamerican=se01q04.wav        local # No! Foolish Amerikanski!
  74.     sound        sl_enough=se01q05.wav                local # Enough!
  75.     sound        sl_what=se01q07.wav                    local # What? (when not found)
  76.     sound        sl_haltyou=se01q08.wav                local # Halt You!    
  77.     sound        sl_goodjoke=se01q03.wav                local # Good Joke. (4.13 sec)
  78.  
  79.     sound        music0=mus_gen_indyrelief.wav        local
  80.  
  81. # .................................. THINGS ....................................
  82.  
  83.     thing        indypos
  84.     thing        guardpos
  85.  
  86.       thing        indyactor                                local # create on the fly
  87.     thing        bunk_indy                                local # create on the fly
  88.     thing        sailor                                    local # create on the fly
  89.  
  90.      thing        door0
  91.     thing        movepos0                                nolink
  92.     thing        movepos1                                nolink
  93.     thing        movepos2                                nolink
  94.     thing        movepos3                                nolink
  95.     thing        movepos4                                nolink
  96.     thing        evadepos                                nolink
  97.     thing        campos0                                    nolink
  98.     thing        campos1                                    nolink
  99.     thing        brig_cam_1                                nolink
  100.     thing        brig_ct_1                                nolink
  101.     thing        brig_ct_2                                nolink
  102.     thing        brig_mk_1                                nolink
  103.     thing        brig_mk_2                                nolink
  104.     thing        brig_mk_3                                nolink
  105.     thing        brig_ct_repeat                            local # create on the fly
  106.     thing        sailor_tgt                                local # create on the fly
  107.     thing        indy_tgt                                local # create on the fly
  108.  
  109.     thing        switch0
  110.     thing        switch1
  111.  
  112.     thing        player                                local
  113.     int        touching                                local
  114.     int        movestatus                                local
  115.  
  116.     surface    doorway                                 mask=0x004
  117.  
  118. # ........................... CAMERA FADE THINGS ...............................
  119.  
  120.     thing        fadeghost                                nolink
  121.     thing        fadething                                nolink
  122.     thing        fader2                                    nolink
  123.  
  124. # ........................ OTHER ENGINE REFERENCES .............................
  125.             
  126.     sector        hall
  127.     sector        vent
  128.     sector        nitch
  129.     sector        bed
  130.     sector        targetsector                            local # var
  131.  
  132.     template    indy_tpl=indy_actor                        local
  133.     template    guard_tpl=sailor_tokarev                local
  134.     template    ghost_tpl=ghost                            local
  135.     
  136. # ............................... VARIABLES ....................................
  137.  
  138.     vector        v_dpos                                    local # door position
  139.     vector        v_ipos                                    local # indy position
  140.     vector        v_idvec                                    local # indy-to-door vec
  141.     vector        v_drvec                                    local # door right vec
  142.     vector        v_tchdoorPYR                            local
  143.     vector        v_arrdoorPYR                            local
  144.     vector        v_closedoorPYR                            local # door aim
  145.     vector        v_targetpos                                local # target creation
  146.  
  147.     flex        OpenDoors                                local
  148.     flex        CloseDoors                                local
  149.     flex        Hiding                                    local
  150.     flex        end_hiding                                local
  151.     flex        in_nitch                                local
  152.     flex        on_bed                                    local
  153.     flex        randlocklines                            local
  154.     flex        randnogolines                            local
  155.     
  156.     flex        f_iposcheck                                local # dot result indy relative to door
  157.     flex        dooryaw                                    local
  158.     flex        timeratio                                local
  159.     flex        reopentime                                local
  160.     flex        f_arrdoorY                                local # door yaw
  161.     flex        closeangle                                local
  162.     flex        doortime=1.0                            local
  163.     flex        in_rotRate                                local
  164.     flex        sl_rotRate                                local
  165.  
  166.     int            alreadytouched=0                        local    
  167.     int            dl_newline=50                            local
  168.     int            dl_oldline=50                            local
  169.     int            ng_newline=50                            local
  170.     int            ng_oldline=50                            local
  171.     int            nogoffset=7                                local
  172.     int            lineindex                                local # indexes sound array
  173.     int            open=0                                    local
  174.     int            initch=0                                local
  175.     int            onbed=0                                    local
  176.     int            waittime=0                                local
  177.     int            solved=0                                local
  178.     int            invent=0                                local
  179.     int            notnow=0                                local
  180.     int            endhide=0                                local
  181.     int            in_keytrack1                            local
  182.     int            wheregrd=0                                local
  183.     int            sayit                                    local
  184.     int            sender                                    local
  185.     int            speak0                                    local
  186.     int            cursound                                local
  187.     int            callevent=0                                local
  188.     int            lookedalready=0                            local
  189.     int            in_track1                                local
  190.     int            nocontrol=0                                local
  191.     int            caughtinbrig=0                            local
  192.     int            indyexists=0                            local
  193.     int            indytargexists=0                        local
  194.     int            sailorexists=0                            local
  195.     int            sailtargexists=0                        local
  196.     int            curhealth                                local
  197.     
  198.     vector        v_ButLook local   
  199.     vector        v_IndyLook local   
  200.     flex        f_dot    local
  201.  
  202. # .............................. HAL DOOR STUFF ................................
  203.  
  204.     # NOTE:  door0 has 4 states...
  205.     # closed    --> open == 0 (init state)
  206.     # opening    --> open == 1
  207.     # open        --> open == 2
  208.     # closing    --> open == 3
  209.  
  210. end
  211.  
  212. # ==============================================================================
  213.  
  214. code
  215.  
  216. # ..............................................................................
  217.  
  218. startup:
  219.  
  220.     player=GetLocalPlayerThing(); 
  221.     v_closedoorPYR = GetThingLVecPYR(door0);
  222.     SetThingFlags(fadething, 0x80000);
  223.  
  224.     return;
  225.  
  226. # ..............................................................................
  227.  
  228. activated:
  229.  
  230.     if (notnow == 1)
  231.     {
  232.         return;
  233.     }
  234.  
  235.     sender = GetSenderRef();
  236.  
  237.     if ( (sender == switch0) || (sender == switch1) )
  238.     {
  239.         // Make sure Indy facing button so that he can't activate from other side of thin wall
  240. //        DebugPrint("Brig Door Activated");
  241.         v_ButLook = GetThingLVec(GetSenderRef());
  242.         v_IndyLook = GetThingLVec(player);
  243.         f_dot = VectorDot(v_ButLook, v_IndyLook);
  244. //        DebugFlex(f_dot, "dot");
  245.         if (f_dot < 0.0)
  246.         {
  247.             return;
  248.         }
  249.     }
  250.  
  251.     if (sender == switch0)            # inside
  252.     {
  253.         notnow = 1;
  254.  
  255.         MakeMeStop();
  256.         DeselectWeaponWait(player);
  257.  
  258.         StartCutscene(0);
  259.  
  260.         PlayMode(player, 60, 1);
  261.         Sleep(0.5);
  262.  
  263.         # Indy realizes the brig door is locked...
  264.         Call randlocklines;
  265.         WaitForSound(speak0);
  266.         notnow = 0;
  267.         EndCutscene();
  268.         ClearActorFlags(player, 0x200000);
  269.     }
  270.  
  271.     if (sender == switch1)         # outside
  272.     {
  273.         notnow = 1;
  274.  
  275. #        StopThing(player);
  276.         MakeMeStop();
  277.         DeselectWeaponWait(player);
  278.  
  279.         StartCutscene(0);
  280.  
  281.         PlayMode(player, 60, 1);
  282.         Sleep(0.5);
  283.  
  284.         # Indy refuses to re-open the brig door...
  285.         call randnogolines;
  286.         WaitForSound(speak0);
  287.         notnow = 0;
  288.         EndCutscene();
  289.         ClearActorFlags(player, 0x200000);
  290.     }
  291.  
  292.     if ((sender == door0) && (solved == 0))
  293.     {
  294.         notnow = 1;
  295.  
  296. #        StopThing(player);
  297.         MakeMeStop();
  298.         DeselectWeaponWait(player);
  299.  
  300.         StartCutscene(0);
  301.  
  302.         # Indy bangs on the brig door...
  303.         callevent = 1; # constrain callback
  304.         CaptureThing(player);                    # because Randy said so...
  305.         PlayKey(player, in_hitdoor, 4, 0x12, 1);
  306.         callevent = 0;
  307.         EndCutscene();
  308.         ClearActorFlags(player, 0x200000);
  309.         
  310.         # Sailor delays for increasing amounts of time...
  311.         # NOTE:
  312.         # 1st delay == 0
  313.         # 2nd delay == 6 sec
  314.         # 3rd delay == 12
  315.         # nth delay == 18 thereafter
  316.         
  317.         if (waittime != 0)
  318.         {
  319.             Sleep(waittime);
  320.         }
  321.  
  322.         waittime = (waittime + 6);
  323.         if (waittime >= 18)
  324.         {
  325.             waittime = 18;
  326.         }
  327.  
  328.         # Make a sailor outside (here and here only)...
  329.         if (sailorexists != 0)
  330.         {
  331.             DestroyThing(sailor);
  332.         }
  333.         sailor = CreateThing(guard_tpl, guardpos);
  334.         AISetCutsceneMode(sailor);
  335.         CaptureThing(sailor);
  336.         sailorexists = 1;
  337.         SetWeaponModel(sailor, 4); # Tokarev pistol
  338.         ClearThingFlags(sailor, 0x80000);
  339.         
  340.         # Establish a camera target near sailor...
  341.         if (sailtargexists != 0)
  342.         {
  343.             DestroyThing(sailor_tgt);
  344.         }
  345.         v_targetpos =
  346.             VectorAdd(VectorTransformToOrient(sailor, '0.0 0.02 0.02'), GetThingPos(sailor));    
  347.         targetsector = FindNewSectorFromThing(sailor, v_targetpos);
  348.         sailor_tgt =
  349.             CreateThingAtPos(ghost_tpl, targetsector, v_targetpos, '0 0 0');
  350.         CaptureThing(sailor_tgt);
  351.         sailtargexists = 1;
  352.         AttachThingToThing(sailor_tgt, sailor);
  353.         SetActorFlags(player, 0x200000); # lose control
  354.         StopThing(player);
  355.  
  356.         if (invent != 1)
  357.         {
  358.         #    StopThing(player);
  359.             MakeMeStop();
  360.         }
  361.  
  362.         DeselectWeaponWait(player);
  363.         StartCutscene(1);
  364.         
  365.         # Cut to sailor outside brig...
  366.             SetCameraPosInterp(2, 0);
  367.         SetCameraFocus(2, campos1);
  368.         SetCameraSecondaryFocus(2, sailor_tgt);
  369.         SetCurrentCamera(2);
  370.         SetThingFlags(player, 0x80000);
  371.         
  372.         # Make a new leading man (here and here only!)...
  373.         if (indyexists != 0)
  374.         {
  375.             DestroyThing(indyactor);
  376.         }
  377.         indyactor = CreateThing(indy_tpl, indypos);
  378.         CaptureThing(indyactor);
  379.         indyexists = 1;
  380.  
  381.         if ((initch != 1) && (invent != 1) && (onbed != 1))
  382.         {
  383.         #    StopThing(player);
  384.             MakeMeStop();
  385.             SetThingAlpha(indyactor, 1.0);
  386.             ClearThingFlags(indyactor, 0x80000);
  387.         }
  388.  
  389.         # Sailor activates switch outside to open brig door...
  390.  
  391.         PlayKey(sailor, actdoor, 4, 0x12, 0);
  392.  
  393.     PlaySoundLocal(pullgun, 1.0, 0.0, 0x0, 0);        
  394.  
  395.         Sleep(0.5);
  396.         MoveToFrame(switch0, 1, 1);
  397.         MoveToFrame(switch1, 1, 1);
  398.         StopThing(player);
  399.         call OpenDoors;
  400.     }
  401.  
  402.     return;
  403.  
  404. # ..............................................................................
  405.  
  406. arrived:
  407.  
  408.     if (GetSenderRef() != door0)
  409.     {
  410.         return;
  411.     }
  412.  
  413.     # Sailor action starts when the door finishes opening...
  414.  
  415.     if (open == 1)
  416.     {
  417.         open = 2; # door is now open
  418.  
  419.         if (solved == 0)
  420.         {
  421.             # Walk sailor to position outside the open door...
  422.             AISetMoveSpeed(sailor, 1.0);
  423.             AISetLookThingEyeLevel(sailor, movepos0);
  424.             AISetMoveThing(sailor, movepos0, 1);
  425.  
  426.             if(invent == 1) # player hiding in vent
  427.             {
  428.                 goto Hiding;
  429.                 return;
  430.             }
  431.  
  432.             if (initch == 1) # player hiding in nitch
  433.             {
  434.                 goto in_nitch;
  435.                 return;
  436.             }
  437.  
  438.             if (onbed == 1) # player hiding on bed
  439.             {
  440.                 goto on_bed;
  441.                 return;
  442.             }
  443.  
  444.             AISetLookThing(sailor, indyactor);
  445.             Sleep(0.5);
  446.  
  447.             # Cut to shot of sailor from inside brig...
  448.             SetCameraLookInterp(2, 0);
  449.             SetCameraFocus(2, campos0);
  450.             SetCameraSecondaryFocus(2, sailor_tgt);
  451.             SetCurrentCamera(2);
  452.  
  453.             # Guard speaks to Indy prisoner...
  454.  
  455.             if (waittime < 7)
  456.             {
  457.                 # Indy feigns illness...
  458.                 PlayVoice(sailor, sl_nobackup, 1.0, 1);
  459.                 cursound = PlayVoice(indyactor, in_seasick, 1.0, 0);
  460.                 Sleep(1.0);
  461.                 PlayKey(indyactor, in_rtarmup, 4, 0x12, 0);
  462.                 WaitForSound(cursound);
  463.                 PlayVoice(sailor, sl_goodjoke, 1.0, 0);
  464.                 Sleep(3.0);
  465.             }
  466.  
  467.             if ((waittime > 6) && (waittime < 13))
  468.             {
  469.                 PlayVoice(sailor, sl_foolishamerican, 1.0, 1);
  470.             }
  471.  
  472.             if (waittime > 12)
  473.             {
  474.                 PlayVoice(sailor, sl_enough, 1.0, 1);
  475.             }
  476.  
  477.             AISetLookThingEyeLevel(sailor, movepos4);
  478.             AISetMoveThing(sailor, movepos4, 0);
  479.             Sleep(1.2);
  480.             call CloseDoors;
  481.  
  482.             return;
  483.         }
  484.  
  485.         # Don't sleep, time...
  486.         SetTimer(2.0);
  487.         return;
  488.     }
  489.  
  490.     if (open == 3)
  491.     {        
  492.         # This is how player regains control...
  493.  
  494.         if (alreadytouched == 1)
  495.         {
  496.             return;
  497.         }
  498.         SetAdjoinFlags(doorway, 2);
  499.         MoveToFrame(switch0, 0, 1);
  500.         MoveToFrame(switch1, 0, 1);
  501.         v_arrdoorPYR = GetThingLVecPYR(door0);
  502.         f_arrdoorY = Truncate(VectorY(v_arrdoorPYR)); # to lowest integer degree
  503.  
  504.         if (f_arrdoorY == 0)
  505.         {
  506.             SetThingLVecPYR(door0, v_closedoorPYR); # slam it closed for sure
  507.         }
  508.  
  509.         if (nocontrol == 1)
  510.         {
  511.             # Go no further if Indy is being sent back to bunk...
  512.             return;
  513.         }
  514.  
  515.         if (solved == 1)
  516.         {
  517.             DestroyThing(sailor_tgt);
  518.             DestroyThing(sailor);
  519.             sailorexists = 0;
  520.             sailtargexists = 0;
  521.             DestroyThing(indy_tgt);
  522.             DestroyThing(indyactor);
  523.             indyexists = 0;
  524.             indytargexists = 0;
  525.                     
  526.             ClearThingFlags(player, 0x80000);
  527.             SetCurrentCamera(1);
  528.             EndCutscene();
  529.             ClearActorFlags(player, 0x200000);
  530.         }
  531.  
  532.         open = 0; # door is now closed
  533.         notnow = 0; 
  534.  
  535.         if (solved == 0)
  536.         {
  537.             # Player was not stopped by a touch...
  538.             if ((initch != 1) && (invent != 1) && (onbed != 1))
  539.             {
  540.                 TeleportThing(player, indypos);
  541.             }
  542.             SetThingFlags(indyactor, 0x80000);            
  543.             ClearThingFlags(player, 0x80000);
  544.             SetCurrentCamera(1);
  545.             ResetCameraFOV(0, 0.0);
  546.             ClearActorFlags(player, 0x200000);
  547.             EndCutscene();
  548.             return;
  549.         }
  550.  
  551.         return;
  552.     }
  553.  
  554. # ..............................................................................
  555.  
  556. entered:
  557.  
  558.     sender = GetSenderRef();
  559.  
  560.     if ((sender == hall) && (GetSourceRef() == player))
  561.     {        
  562.         if (solved == 1)
  563.         {
  564.             return;
  565.         }
  566.  
  567.         # Player has escaped...
  568.         solved = 1;
  569.  
  570.         if (open > 0)
  571.         {
  572.             # Show Indy trapping the guard...
  573.             StopThing(sailor);
  574.  
  575.             MakeMeStop();
  576. #            DeselectWeaponWait(player);
  577.  
  578.             Sleep(0.01);
  579.             SetThingFlags(player, 0x80000); # invisible
  580.             endhide = 1;
  581.  
  582.             CopyPlayerHolsters(player, indyactor);
  583.  
  584.             StartCutscene(1);
  585.             TeleportThing(indyactor, evadepos);
  586.         
  587.             # Establish a camera target near Indy...
  588.             if (indytargexists != 0)
  589.             {
  590.                 DestroyThing(indy_tgt);
  591.             }
  592.             v_targetpos =
  593.                 VectorAdd(VectorTransformToOrient(indyactor, '-0.02 0.00 0.015'), GetThingPos(indyactor));    
  594.             targetsector = FindNewSectorFromThing(indyactor, v_targetpos);
  595.             indy_tgt =
  596.                 CreateThingAtPos(ghost_tpl, targetsector, v_targetpos, '0 0 0');
  597.             CaptureThing(indy_tgt);
  598.             indytargexists = 1;
  599.             AttachThingToThing(indy_tgt, indyactor);
  600.             
  601.             # Put Indy outside door...
  602.             ClearThingFlags(indyactor, 0x80000);
  603.             SetThingAlpha(indyactor, 1.0);
  604.             
  605.             # Cut to shot of Indy closing door on the guard...
  606.             SetCameraFocus(2, campos1);
  607.             SetCameraSecondaryFocus(2, indy_tgt);
  608.             SetCurrentCamera(2);
  609.  
  610.             # Turn Indy toward door switch...
  611.             AISetLookThingEyeLevel(indyactor, guardpos);
  612.             Sleep(0.2);
  613.  
  614.             # Get sailor after player...
  615.             TeleportThing(sailor, movepos2);
  616.             AISetMoveThing(sailor, movepos1, 0);
  617.  
  618.             # Walk Indy to switch...
  619.             AISetMoveSpeed(indyactor, 0.9);
  620.             AISetMoveThing(indyactor, guardpos, 0);
  621.             Sleep(0.9);
  622.             AISetLookThing(indyactor, switch1);
  623.  
  624.             # Sailor: "Halt, you!"
  625.             AISetLookThingEyeLevel(sailor, indypos);
  626.             SetCollideType(sailor, 0); # so he can't prevent door closing
  627.             SetThingMaxRotVel(sailor, 200.0);
  628.             AISetLookThing(sailor, indyactor);
  629.             PlayVoice(sailor, sl_haltyou, 1.0, 0);
  630.             Sleep(0.5);
  631.             AISetMoveThing(sailor, indypos, 0);
  632.  
  633.     AIWaitForStop(sailor);
  634.             PlaySoundLocal(music0, 1.0, 0.0, 0x0, 0);        
  635.             PlayKey(indyactor, in_close, 4, 0x12, 0);
  636.             Sleep(0.5);
  637.             MoveToFrame(switch0, 0, 1);
  638.             MoveToFrame(switch1, 0, 1);
  639.             Call CloseDoors;
  640.             TeleportThing(player, indyactor);
  641.             SetCurrentCamera(1);
  642.         }
  643.  
  644.         return;
  645.     }
  646.  
  647.     if (sender == vent)
  648.     {
  649.         invent = 1;
  650.         return;
  651.     }
  652.  
  653.     if (sender == nitch)
  654.     {
  655.         initch = 1;
  656.         return;
  657.     }
  658.  
  659.     if (sender == bed)
  660.     {
  661.         onbed = 1;
  662.         invent = 0;
  663.         return;
  664.     }
  665.  
  666.     return;
  667.  
  668. # ..............................................................................
  669.  
  670. exited:
  671.  
  672.     sender = GetSenderRef();
  673.  
  674.     if (sender == nitch)
  675.     {
  676.         initch = 0;
  677.         return;
  678.     }
  679.  
  680.     if (sender == bed)
  681.     {
  682.         onbed = 0;
  683.         return;
  684.     }
  685.  
  686.     return;
  687.  
  688. # ..............................................................................
  689.  
  690. touched:
  691.     
  692.     sender = GetSenderRef();
  693.  
  694.     if (touching != 0)
  695.     {
  696.         return;
  697.     }
  698.  
  699.     touching = 1;
  700.     
  701.     if ((sender == sailor) && (GetSourceRef() == player))
  702.     {
  703.         endhide = 1;
  704.         SetActorFlags(player, 0x200000); # no control
  705.         StopThing(sailor);
  706.         MakeMeStop();
  707.         DeselectWeaponWait(player);
  708.         StartCutscene(1);
  709.         TeleportThing(indyactor, player);
  710.         SetThingFlags(player, 0x80000);
  711.         ClearThingFlags(indyactor, 0x80000);
  712.         SetThingAlpha(indyactor, 1.0); # need this?
  713.         AISetLookThing(sailor, indyactor);
  714.         AISetLookThing(indyactor, sailor);
  715.         AIWaitForStop(indyactor);
  716.  
  717.         # Indy surrenders...
  718.         in_track1 = PlayKey(indyactor, in_raisehands, 4, 0x14, 0);        
  719.         Sleep(0.8);
  720.         PlayKey(sailor, acthit, 4, 0x12, 0);
  721.         Sleep(0.5);
  722.         Stopkey(indyactor, in_track1, 0.0);
  723.         in_track1 = PlayKey(indyactor, in_fall, 4, 0x14, 0);
  724.  
  725.         # TO DO: add bop sound...
  726.         PlaySoundLocal(bop_indy, 1.0, 0, 0x0, 0);
  727.  
  728.         # Record some damage (yes, player can die this way)...
  729.         curhealth = GetThingHealth(player);
  730.         SetThingHealth(player, (curhealth - 40));
  731.         Sleep(1.0);
  732.  
  733.         # Fade out...
  734.         SetCollideType(fadething, 0);    
  735.         ClearThingFlags(fadething, 0x80000);
  736.         SetThingAlpha(fadething, 0.0); # make sure fader is transparent
  737.         SetCameraFadeThing(2, fadething, fadeghost, 0);
  738.         SetCurrentCamera(2);
  739.         Sleep(0.01);
  740.         ThingFadeAnim(fadething, 0.0, 1.0, 1.0, 0);
  741.         ThingFadeAnim(sailor, 1.0, 0.0, 1.0, 0);
  742.         ThingFadeAnim(indyactor, 1.0, 0.0, 1.0, 0);
  743.         Sleep(1.0);
  744.  
  745.         caughtinbrig = 1;
  746.         Call user0; # it's just a label
  747.  
  748.         touching = 0;
  749.         return;
  750.     }
  751.  
  752.     if ((sender == door0) && (open == 3))
  753.     {
  754.         # Do this if player touches closing door...
  755.  
  756.         alreadytouched = 1; # do once only
  757.         # check if Indy is touching back side of door...
  758.         v_dpos = GetThingPos(door0); # door hinge
  759.         v_ipos = GetThingPos(player); # our hero
  760.          v_idvec = VectorNorm(VectorSub(v_dpos, v_ipos)); # direction between indy & door 
  761.         v_drvec = GetThingLVec(door0); # check 90 to door plane
  762.         f_iposcheck = VectorDot(v_idvec, v_drvec); # places indy in- or outside door
  763.  
  764.         if (f_iposcheck > 0)
  765.         {
  766.             # Don't re-open if Indy is touching back side...
  767.             touching = 0;
  768.             return;
  769.         }
  770.             
  771.         open = 1; # door is opening again
  772.         StopThing(door0);
  773.         Sleep(0.1); # let engine update
  774.         v_tchdoorPYR = GetThingLVecPYR(door0);
  775.         closeangle = (Abs(VectorY(v_closedoorPYR)) + 90);
  776.         dooryaw = (closeangle - Abs(VectorY(v_tchdoorPYR))); # how far is door open?
  777.         timeratio = (abs(dooryaw) / 90); # what percentage?
  778.         reopentime = ( doortime * timeratio); # calculate time
  779.         Rotate(door0, dooryaw, 1, reopentime); # re-open
  780.     }
  781.  
  782.     touching = 0;
  783.     return;
  784.  
  785. # ..............................................................................
  786.  
  787. callback:
  788.  
  789.     if (callevent != 0)
  790.     {
  791.         PlaySoundThing(bangdoor, door0, 1, 5, 20, 0);
  792.     }
  793.  
  794.     return;
  795.  
  796. # ..............................................................................
  797.  
  798. timer:
  799.  
  800.     call CloseDoors;
  801.  
  802.     return;
  803.  
  804. # ..............................................................................
  805.  
  806. crossed:
  807.     If((GetSenderRef() == doorway) && (GetSourceRef() == sailor))
  808.     {
  809.  
  810.     # Set doorway no-move.
  811.     ClearAdjoinFlags(doorway, 2);
  812.     }
  813.     return;
  814.  
  815. # ..............................................................................
  816. # Player thrown back in cell...
  817. # ..............................................................................
  818.  
  819. user0:
  820.  
  821.     # Thwarted by his captors, Indy broods on his bunk...
  822.         
  823.     # prevent regaining control via door arrivial...
  824.     nocontrol = 1;
  825.     
  826.     # Prep...
  827.     brig_ct_repeat = CreateThing(ghost_tpl, brig_ct_1);
  828.     ClearThingFlags(fader2, 0x80000);
  829.     SetThingAlpha(fader2, 1.0);
  830.  
  831.     # Cut to the brig...
  832.     SetCameraPosInterp(2, 0);
  833.     SetCameraLookInterp(2, 0);
  834.     SetCameraFocus(2, brig_cam_1);
  835.     SetCameraSecondaryFocus(2, brig_ct_repeat);
  836.     SetCurrentCamera(2);
  837.     SetCameraFOV(61, 0, 0.0);
  838.  
  839.     # Make sure brig door is closed...
  840.     if (caughtinbrig == 1)
  841.     {
  842.         if (open == 2)
  843.         {
  844.             Call CloseDoors;
  845.             Sleep(doortime);
  846.         }
  847.         else
  848.         {
  849.             cursound = PlaySoundThing(closesnd, door0, 1, 5, 10, 0);
  850.             WaitForSound(cursound);        
  851.         }
  852.             
  853.         # And clean up if Indy was caught on the premises...
  854.         StopKey(indyactor, in_track1, 0.0);
  855.         SetThingFlags(indyactor, 0x80000);
  856.         SetThingAlpha(indyactor, 1.0);
  857.         SetThingFlags(sailor, 0x80000);
  858.         SetThingAlpha(sailor, 1.0);
  859.     }
  860.     else
  861.     {
  862.         cursound = PlaySoundThing(closesnd, door0, 1, 5, 10, 0);
  863.         WaitForSound(cursound);
  864.     }
  865.  
  866.     bunk_indy = CreateThing(indy_tpl, brig_mk_3);
  867.     CaptureThing(bunk_indy);
  868.     ClearThingFlags(bunk_indy, 0x80000);
  869.     CopyPlayerHolsters(player, bunk_indy);
  870.     in_track1 = PlayKey(bunk_indy, in_standup, 4, 0x12, 0);
  871.     PauseKey(bunk_indy, in_track1); # hold
  872.  
  873.     # Fade in on Indy...
  874.     SetThingFlags(fadething, 0x80000); # lose this for now
  875.     ThingFadeAnim(fader2, 1.0, 0.0, 1.0, 0);
  876.     Sleep(1.0);
  877.     SetThingFlags(fader2, 0x80000);
  878.  
  879.     # Indy stands up...
  880.     ResumeKey(bunk_indy, in_track1);
  881.     PlayVoice(bunk_indy, ungh, 1.0, 0);
  882.     SetCameraFOV(82, 1, 2.2);
  883.     Sleep(1.2);
  884.     StopKey(bunk_indy, in_track1, 0.0);
  885.     AttachThingToThing(brig_ct_repeat, bunk_indy);
  886.     AISetMoveSpeed(bunk_indy, 0.9);
  887.     AISetLookThingEyeLevel(bunk_indy, brig_mk_1);
  888.     Sleep(0.1);
  889.     AISetMoveThing(bunk_indy, brig_mk_1, 1);
  890.     AISetLookThingEyeLevel(bunk_indy, brig_mk_2);
  891.     Sleep(0.3);
  892.  
  893.     # Clean up & restore control...
  894.     SetThingAlpha(player, 1.0);
  895.     TeleportThing(player, bunk_indy);
  896.     SetThingAlpha(player, 1.0); # make sure he's opaque
  897.     SetCameraInterpSpeed(2, 1);    # reset default
  898.     SetCameraLookInterp(2, 0);
  899.     SetCameraPosInterp(2, 0);
  900.     SetCameraPosition(1, GetThingPos(brig_cam_1)); # prep follow-cam
  901.     SetCurrentCamera(1);
  902.     ResetCameraFOV(0, 0.0);
  903.     ClearThingFlags(player, 0x80000);
  904.     DestroyThing(brig_ct_repeat);
  905.     DestroyThing(bunk_indy);
  906.     caughtinbrig = 0;
  907.     nocontrol = 0;
  908.     solved = 0; # still a prisoner
  909.     notnow = 0; # allowed to try again
  910.     open = 0; # door is closed
  911.     EndCutscene();
  912.     ClearActorFlags(player, 0x200000);
  913.  
  914.     return;
  915.  
  916. # ..............................................................................
  917.  
  918. OpenDoors:
  919.  
  920.     Rotate(door0, 90, 1, doortime);
  921.     PlaySoundThing(opensnd, door0, 1, 5, 10, 0);
  922.     open = 1;
  923.     alreadytouched = 0; # init every time door opens
  924.  
  925.     return;
  926.  
  927. # ..............................................................................
  928.  
  929. CloseDoors:
  930.  
  931.     Rotate(door0, -90, 1, doortime);
  932.     PlaySoundThing(closesnd, door0, 1, 5, 10, 0);
  933.     open = 3;
  934.     alreadytouched = 0; # Indy can stop it again
  935.  
  936.     return;
  937.  
  938. # ..............................................................................
  939. # Player hiding options...
  940. # ..............................................................................
  941.  
  942. Hiding:                            # in vent
  943.  
  944.     endhide = 0;
  945.     ClearThingFlags(sailor, 0x80000);
  946.     AISetLookThingEyeLevel(sailor, movepos1);
  947.     Sleep(1.0);
  948.        SetCameraPosInterp(2, 0);
  949.     SetCameraFocus(2, campos0);
  950.     SetCameraSecondaryFocus(2, sailor_tgt);
  951.     SetCurrentCamera(2);
  952.     PlayVoice(sailor, sl_what, 1.0, 1);
  953.     AISetMoveThing(sailor, movepos1, 1);
  954.  
  955.     if (lookedalready == 0)
  956.     {
  957.         PlayKey(sailor, actlook, 4, 0x12, 1);
  958.         lookedalready = 1;
  959.     }
  960.  
  961.     AISetLookThingEyeLevel(sailor, movepos2);
  962.     AISetMoveThing(sailor, movepos2, 1);
  963.     AISetLookThingEyeLevel(sailor, movepos3);
  964.     AISetMoveThing(sailor, movepos3, 1);
  965.     ClearThingFlags(player, 0x80000);
  966.     EndCutscene();
  967.     SetCurrentCamera(1);
  968.     ClearActorFlags(player, 0x200000);
  969.  
  970.     # time to leave cell...
  971.     Sleep(8.0);
  972.     goto end_hiding;
  973.  
  974.     return;
  975.  
  976. # ..............................................................................
  977.  
  978. end_hiding:
  979.  
  980.     if (endhide == 1)
  981.     {
  982.         return;
  983.     }
  984.  
  985.     AISetLookThingEyeLevel(sailor, movepos2);
  986.     AISetMoveThing(sailor, movepos2, 1);
  987.     wheregrd = 1;
  988.  
  989.     if (endhide == 1)
  990.     {
  991.         return;                # did he get touched?
  992.     }
  993.  
  994.     AISetLookThingEyeLevel(sailor, movepos1);
  995.     AISetMoveThing(sailor, movepos1, 1);
  996.     wheregrd = 2;
  997.  
  998.     if (endhide == 1)
  999.     {
  1000.         return;                # did he get touched?
  1001.     }
  1002.     AISetLookThingEyeLevel(sailor, movepos0);
  1003.     AISetMoveThing(sailor, movepos0, 1);
  1004.     wheregrd = 3;
  1005.  
  1006.     if (endhide == 1)
  1007.     {
  1008.         return;                # did he get touched?
  1009.     }
  1010.  
  1011.     if (solved == 0) 
  1012.     {
  1013.         AISetLookThingEyeLevel(sailor, movepos4);
  1014.         AISetMoveThing(sailor, movepos4, 1);
  1015.         Call CloseDoors;
  1016.     }
  1017.  
  1018.     return;
  1019.  
  1020. # ..............................................................................
  1021.  
  1022. in_nitch:
  1023.  
  1024.     ClearThingFlags(sailor, 0x80000);
  1025.     AISetLookThingEyeLevel(sailor, movepos1);
  1026.     Sleep(1.0);
  1027.     SetCameraPosInterp(2, 0);
  1028.     SetCameraFocus(2, campos0);
  1029.     SetCameraSecondaryFocus(2, sailor_tgt);
  1030.     SetCurrentCamera(2);
  1031.     PlayVoice(sailor, sl_what, 1.0, 1);
  1032.     AISetMoveThing(sailor, movepos1, 1);
  1033.  
  1034.     if (lookedalready == 0)
  1035.     {
  1036.         PlayKey(sailor, actlook, 4, 0x12, 1);
  1037.         lookedalready = 1;
  1038.     }
  1039.  
  1040.     AISetLookThingEyeLevel(sailor, movepos2);
  1041.     AISetMoveThing(sailor, movepos2, 1);
  1042.     AISetLookThing(sailor, player);
  1043.     cursound = PlayVoice(sailor, sl_nobackup, 1.0, 0);
  1044.     WaitForSound(cursound);
  1045.     AISetLookThingEyeLevel(sailor, movepos1);
  1046.     AISetMoveThing(sailor, movepos1, 1);
  1047.     AISetLookThingEyeLevel(sailor, movepos0);
  1048.     AISetMoveThing(sailor, movepos0, 1);
  1049.     AISetLookThingEyeLevel(sailor, movepos4);
  1050.     AISetMoveThing(sailor, movepos4, 1);
  1051.     Call CloseDoors;
  1052.     SetCurrentCamera(1);
  1053.     ClearThingFlags(player, 0x80000);
  1054.     EndCutscene();
  1055.     PlayVoice(player, in_betterspot, 1.0, 1);
  1056.     ClearActorFlags(player, 0x200000);
  1057.  
  1058.     return;
  1059.  
  1060. # ..............................................................................
  1061.  
  1062. on_bed:
  1063.  
  1064.     ClearThingFlags(sailor, 0x80000);
  1065.     AISetLookThingEyeLevel(sailor, movepos1);
  1066.     Sleep(1.0);
  1067.     SetCameraPosInterp(2, 0);
  1068.     SetCameraFocus(2, campos0);
  1069.     SetCameraSecondaryFocus(2, sailor_tgt);
  1070.     SetCurrentCamera(2);
  1071.     PlayVoice(sailor, sl_what, 1.0, 1);
  1072.     AISetMoveThing(sailor, movepos1, 1);
  1073.  
  1074.     if (lookedalready == 0)
  1075.     {
  1076.         PlayKey(sailor, actlook, 4, 0x12, 1);
  1077.         lookedalready = 1;
  1078.     }
  1079.  
  1080.     AISetLookThing(sailor, player);
  1081.     cursound = PlayVoice(sailor, sl_nobackup, 1.0, 0);
  1082.     WaitForSound(cursound);
  1083.     AISetLookThingEyeLevel(sailor, movepos0);
  1084.     AISetMoveThing(sailor, movepos0, 1);
  1085.     AISetLookThingEyeLevel(sailor, movepos4);
  1086.     AISetMoveThing(sailor, movepos4, 1);
  1087.     Call CloseDoors;
  1088.     SetCurrentCamera(1);
  1089.     ClearThingFlags(player, 0x80000);
  1090.     EndCutscene();
  1091.     PlayVoice(player, in_betterspot, 1.0, 1);
  1092.     ClearActorFlags(player, 0x200000);
  1093.  
  1094.     return;
  1095.  
  1096. # ..............................................................................
  1097.  
  1098. randlocklines:
  1099.  
  1100.     while (dl_newline == dl_oldline)
  1101.     {        
  1102.         dl_newline = RandBetween(0, 19);
  1103.         if (dl_newline < 14)
  1104.         {    
  1105.             dl_newline = RandBetween(0, 2); # ~1/4 chance for 0 thru 2
  1106.         }
  1107.         if (dl_newline > 17)
  1108.         {
  1109.             dl_newline = (dl_newline - 13); # 1/20 chance for 5 or 6 
  1110.         }    
  1111.         if (dl_newline > 15)
  1112.         {
  1113.             dl_newline = 4; # 1/10 chance
  1114.         }
  1115.         if (dl_newline > 13)
  1116.         {
  1117.             dl_newline = 3; # 1/10 chance
  1118.         }
  1119.     }
  1120.     dl_oldline = dl_newline;
  1121.     speak0 = PlayVoice(player, in_sayline[dl_newline], 1.0, 0);
  1122.  
  1123.     return;
  1124.  
  1125. # ..............................................................................
  1126.  
  1127. randnogolines:
  1128.  
  1129.     while (ng_newline == ng_oldline)
  1130.     {        
  1131.         ng_newline = RandBetween(0, 19);
  1132.         if (ng_newline < 14)
  1133.         {    
  1134.             ng_newline = RandBetween(0, 2); # ~1/4 chance for 0 thru 2
  1135.         }
  1136.  
  1137.         if (ng_newline > 17)
  1138.         {
  1139.             ng_newline = (ng_newline - 13); # 1/20 chance for 5 or 6 
  1140.         }    
  1141.         if (ng_newline > 15)
  1142.         {
  1143.             ng_newline = 4; # 1/10 chance
  1144.         }
  1145.         if (ng_newline > 13)
  1146.         {
  1147.             ng_newline = 3; # 1/10 chance
  1148.         }
  1149.     }
  1150.     ng_oldline = ng_newline;
  1151.     lineindex = nogoffset + ng_newline;
  1152.     speak0 = PlayVoice(player, in_sayline[lineindex], 1.0, 0);
  1153.     return;
  1154.  
  1155. end
  1156.  
  1157.